package org.fage.semples.dao;

import java.util.List;

import org.fage.semples.model.ExamScore;
import org.fage.semples.model.ExamScores;
import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository
@Transactional
public class ExamScoreHiberanteDAOImpI extends BaseHibernateDAO<ExamScore> implements ExamScoreHiberanteDAO {

	@Override
	public List<ExamScore> getScoreByUserId(String userId) {
		return this.queryForList("FROM ExamScore WHERE user_id=?", new Object[]{userId});
	}
	
	public List<ExamScore> getScoreBySubId(String subId) {
		return this.queryForList("FROM ExamScore WHERE subject_id=?", new Object[]{subId});
	}
	
	public void addUserExamScore(ExamScore examScore){
		this.save(examScore);
	}
	
	@SuppressWarnings("unchecked")
	@Override
	public List<ExamScores> findAllExamScores() throws Exception {
		String hql = "FROM ExamScores";
		return this.createQuery(hql).list();
	}
	
}
